﻿using ModernShopping.AppCode;
using ModernShopping.AppCode.WebUtil;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace ModernShopping
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ModernShoppingService" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select ModernShoppingService.svc or ModernShoppingService.svc.cs at the Solution Explorer and start debugging.
    public class ModernShoppingService : IModernShoppingService
    {
        public List<Marker> GetListStore(string ProductCode)
        {
            List<Store> listStore = DbStore.GetList(int.Parse(ProductCode));
            return Marker.ParseList(listStore);
        }

        public string GetProductDescription(string ProductCode)
        {
            Product p = DbProduct.GetByCode(int.Parse(ProductCode));
            return p.Description;
        }

        public List<Comment> GetProductComment(string ProductCode, string Take)
        {
            List<ProductComnent> lst = DbProductComment.getList(int.Parse(ProductCode), int.Parse(Take));
            return Comment.parseList(lst);
        }

        public bool CommentProduct(string ProductCode, string Comment, string Username)
        {
            return DbProductComment.Comment(Comment, Username, int.Parse(ProductCode));
        }
    }
}
